﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Nage.Algorithms.Stop
{
    /// <summary>
    /// Fixed steps stop condition class.
    /// </summary>
    public class FixedStepsStopCondition : IStopCondition
    {
        #region Public properties

        /// <summary>
        /// Current step number
        /// </summary>
        public Int32 Current { get; private set; }

        /// <summary>
        /// Total steps amount
        /// </summary>
        public Int32 Total { get; private set; } 

        #endregion

        #region Constructor
        /// <summary>
        /// Creates an instance of fixed steps stop condition class.
        /// </summary>
        /// <param name="stepCount">number of steps</param>
        public FixedStepsStopCondition(int stepCount)
        {
            Current = 0;
            Total = stepCount;
        } 
        #endregion

        #region IsFulfilled
        /// <summary>
        /// Checks if the fixed number of steps has been reached and 
        /// increments the counter
        /// </summary>
        /// <returns>true if stop condition is fulfilled, false otherwise</returns>
        public bool IsFulfilled()
        {
            Boolean result = Current >= Total;
            Current++;
            return result;
        } 
        #endregion
    }
}
